<?

class User extends CI_Controller {

	public function __construct()
	{
		parent::__construct();
		$this->load->model('user_model');
	}

	public function index()
	{
		$this->auth->verify();
	}

	public function login()
	{
		if($_POST)
			$this->auth->login($this->input->post('user_name'), $this->input->post('user_password'));
		else
			$this->auth->verify();
	}

	public function logout()
	{
		$this->auth->check();

		$this->auth->logout();
	}

	public function edit_info($id)
	{
		if($_POST)
		{
			$user['user_name'] = $this->input->post('user_name');
			$user['user_email'] = $this->input->post('user_email');
			if($this->input->post('user_password') != 'xxxxxxxx')
				$user['user_password'] = sha1($this->config->item('auth_pass_salt1').$this->input->post('user_password').$this->config->item('auth_pass_salt2'));

			$this->user_model->update($id,$user);
			exit();
		}
		$data['user'] = $this->user_model->get_user_by_id($id);
		$this->load->view('admin/dialog/edit_user',$data);
	}
}